#!/usr/bin/env python3

import sys
import pygame

def toColor(color):
    if type(color) == tuple:
        return color
    return color >> 16 & 0xFF, color >> 8 & 0xFF, color & 0xFF

def main(argv):
    pygame.init()

    screen = pygame.display.set_mode((600, 480))

    bg = pygame.image.load("./backGround.bmp")
    player = pygame.image.load("./player.bmp")
    player.set_colorkey((247, 0, 255))

    #  screen.blit(bg, (0, 0))
    #  screen.blit(player, (350, 0), (0, 0, 48, 48))
    #  screen.blit(bg, (0, 0), (200, 400, 100, 100))
    #  screen.blit(bg, (200, 200), (400, 100, 100, 100))

    #  pygame.display.update()

    i = 0
    y = 0
    while True:
        e = pygame.event.wait()
        if e.type == pygame.QUIT:
            break
        elif e.type == pygame.MOUSEBUTTONDOWN:
            screen.blit(bg, (0, 0))
            screen.blit(player, (350, y), (0, 48 * i, 48, 48))
            pygame.display.update()
            y += 10
            i += 1
            i %= 2
        elif e.type == pygame.KEYDOWN:
            if e.key == pygame.K_ESCAPE or e.key == pygame.K_q:
                break

    pygame.quit()


if __name__ == '__main__':
    main(sys.argv)

